import demo1.ILinkList;

import java.util.Iterator;
import java.util.LinkedList;
import java.util.ListIterator;

public class Test {
    public static void main(String[] args) {
        LinkedList<Integer> list=new LinkedList<>();
        list.add(2);
        list.addFirst(1);
        //System.out.println(list);
        LinkedList<Integer> list2=new LinkedList<>(list);
        System.out.println(list2);
        for (int i:list2) {
            System.out.print(i+" ");
        }
        System.out.println();
        for (int i = 0; i < list2.size(); i++) {
            System.out.print(list.get(i)+" ");
        }
        System.out.println();
        Iterator<Integer> integerIterator=list2.iterator();
        while (integerIterator.hasNext()){
            System.out.print(integerIterator.next()+" ");
        }
        System.out.println();
        ListIterator<Integer> iterator=list2.listIterator();
        while (iterator.hasNext()){
            System.out.print(iterator.next()+" ");
        }
        System.out.println();
        ListIterator<Integer> iterator2=list2.listIterator(list2.size());
        while (iterator.hasPrevious()){
            System.out.print(iterator.previous()+" ");
        }



    }
}
